/*Messaging mask wearing during the COVID-19 crisis: Ideological differences
Journal of Experimental Political Science
Stephen M Utych*/


/*Below are recodings - Required to run for code to work*/
*Recode / Clean controls

recode gender (2=1) (1=0) (3=.), gen(female)

recode race (2=1) (1 3 4 5 6 = 0), gen(black)
recode race (3=1) (1 2 4 5 6 = 0), gen(latino)
recode race (1 4 6 = 1) (2 3 5 = 0), gen(other_race)

gen republican = .
replace republican = 1 if dem1==1
replace republican = 2 if dem1==2
replace republican = 3 if ind1==2
replace republican = 4 if ind1==3
replace republican = 5 if ind1==1
replace republican = 6 if rep1==2
replace republican = 7 if rep1==1

recode republican (1 2 3 = 1) (4 5 6 7 = 0), gen(dem)
recode republican (5 6 7 = 1) (1 2 3 4 = 0), gen(gop)

*Make DK ideology missing
recode ideo (8=.)

*Binary ideology variable
recode ideo (1 2 3 = 1) (5 6 7 = 0) (4=.), gen(liberal)

*Reverse coding ideology so liberal = highest
gen liberal2 = 8-ideo

*Governor PID and match

gen gop_gov = 0
replace gop_gov = 1 if state==1|state==2|state==3|state==4|state==10|state==11|state==13|state==15|state==16|state==21|state==22|state==25|state==26|state==28|state==30|state==35|state==36|state==37|state==42|state==43|state==44|state==45|state==46|state==47|state==50|state==52

gen copart_gov=.
replace copart_gov=1 if gop_gov==0&dem==1
replace copart_gov=1 if gop_gov==1&gop==1
replace copart_gov=0 if gop_gov==1&dem==1
replace copart_gov=0 if gop_gov==0&gop==1

*Treatments
gen treat=.
replace treat=1 if control!=.
replace treat=2 if prevent!=.
replace treat=3 if promote!=.

recode treat (2=1) (1 3 = 0), gen(prevent_treat)
recode treat (3=1) (1 2 = 0), gen(promote_treat)

label def treat 1 "Control" 2 "Prevention" 3 "Promotion" 
label val treat treat 

label def liberal 1 "Liberal" 0 "Conservative"
label val liberal liberal


*DVs
rename dvs_1 best_soc
rename dvs_2 wont_impact

recode maskpur (2=0), gen(buy_mask)

*Demographics

sum age female if treat!=.
tab race if treat!=.
tab education if treat!=.
tab liberal2 if treat!=.


/*Below are analyses*/

*Table A1 Replication Code
reg wearmask i.treat c.liberal c.liberal#i.treat age female black latino other_race education copart_gov 
logit buy_mask i.treat c.liberal c.liberal#i.treat age female black latino other_race education copart_gov 
reg best_soc i.treat c.liberal c.liberal#i.treat age female black latino other_race education copart_gov 
reg wont_impact i.treat c.liberal c.liberal#i.treat age female black latino other_race education copart_gov


*Figure 1a Replication Code
reg wearmask i.treat c.liberal c.liberal#i.treat age female black latino other_race education copart_gov 
margins, at(treat = (1 2 3) liberal=(0 1)) l(90) saving(e1, replace)
marginsplot, x(treat)  recast(scatter) yscale(range(3.5 6.5)) ylabel(3(1)6) xscale(range(1 1)) graphregion(color(white)) xtitle("") ytitle(Intention to Wear Mask) ti("") scheme(sj) 
graph save file1.gph, replace

logit buy_mask i.treat c.liberal c.liberal#i.treat age female black latino other_race education copart_gov 
margins, at(treat = (1 2 3) liberal=(0 1)) l(90) saving(e1, replace)
marginsplot, x(treat) recast(scatter)  yscale(range(0 .5)) ylabel(0(.1).5) xscale(range(1 3.1)) graphregion(color(white)) xtitle("") ytitle(Intention to Buy Mask) ti("") scheme(sj) 
graph save file2.gph, replace

graph combine file1.gph file2.gph , xcommon rows(1) ti("Figure 1a. Behavioral Measures") scheme(sj)

*Figure 1b Replication Code
reg best_soc i.treat c.liberal c.liberal#i.treat age female black latino other_race education copart_gov 
margins, at(treat = (1 2 3) liberal=(0 1)) l(90) 
marginsplot, x(treat) recast(scatter) yscale(range(3.5 6.5)) ylabel(3(1)6) xscale(range(1 3.1)) graphregion(color(white)) xtitle("") ytitle(Best for Society) ti("") scheme(sj) 
graph save file3.gph, replace

reg wont_impact i.treat c.liberal c.liberal#i.treat age female black latino other_race education copart_gov 
margins, at(treat = (1 2 3) liberal=(0 1)) l(90) saving(e1, replace)
marginsplot, x(treat) recast(scatter) yscale(range(1.5 4.5)) ylabel(2(1)5) xscale(range(1 3.1)) graphregion(color(white)) xtitle("") ytitle(Won't Impact Spread) ti("") scheme(sj) 
graph save file4.gph, replace
 
graph combine file3.gph file4.gph, xcommon rows(1) ti("Figure 1b. Attitudinal Measures") scheme(sj) 



*Table A2 Replication Code
reg wearmask i.treat c.liberal2 c.liberal2#i.treat age female black latino other_race education copart_gov 
logit buy_mask i.treat c.liberal2 c.liberal2#i.treat age female black latino other_race education copart_gov 
reg best_soc i.treat c.liberal2 c.liberal2#i.treat age female black latino other_race education copart_gov 
reg wont_impact i.treat c.liberal2 c.liberal2#i.treat age female black latino other_race education copart_gov 

*Figure 2a Replication Code
reg wearmask i.treat c.liberal2 c.liberal2#i.treat age female black latino other_race education copart_gov 
margins, at(treat = (1 2 3) liberal2=(1(1)7)) l(90) 
marginsplot, x(liberal2) recast(line) yscale(range(3.5 6.5)) ylabel(3(1)6) xscale(range(1 3.1)) graphregion(color(white)) xtitle("Ideology (Higher = More Liberal") ytitle(Intention to Wear Mask) ti("") plot1opts(lpattern(".")) plot2opts(lpattern("--")) scheme(sj) 
graph save file1.gph, replace

logit buy_mask i.treat c.liberal2 c.liberal2#i.treat age female black latino other_race education copart_gov 
margins, at(treat = (1 2 3) liberal2=(1(1)7)) l(90) 
marginsplot, x(liberal2) recast(line)  yscale(range(0 .5)) ylabel(0(.1).5) xscale(range(1 3.1)) graphregion(color(white)) xtitle("Ideology (Higher = More Liberal") ytitle(Intention to Buy Mask) ti("") plot1opts(lpattern(".")) plot2opts(lpattern("--"))scheme(sj) 
graph save file2.gph, replace

graph combine file1.gph file2.gph , xcommon rows(1) ti("Figure 2a. Behavioral Measures") scheme(sj) 

*Figure 2b Replication Code
reg best_soc i.treat c.liberal2 c.liberal2#i.treat age female black latino other_race education copart_gov 
margins, at(treat = (1 2 3) liberal2=(1(1)7)) l(90)
marginsplot, x(liberal2) recast(line) yscale(range(3.5 6.5)) ylabel(3(1)6) xscale(range(1 3.1)) graphregion(color(white)) xtitle("Ideology (Higher = More Liberal") ytitle(Best for Society) ti("") plot1opts(lpattern(".")) plot2opts(lpattern("--"))scheme(sj) 
graph save file3.gph, replace

reg wont_impact i.treat c.liberal2 c.liberal2#i.treat age female black latino other_race education copart_gov 
margins, at(treat = (1 2 3) liberal2=(1(1)7)) l(90)
marginsplot, x(liberal2) recast(line) yscale(range(1.5 4.5)) ylabel(2(1)5) xscale(range(1 3.1)) graphregion(color(white)) xtitle("Ideology (Higher = More Liberal") ytitle(Won't Impact Spread) ti("") plot1opts(lpattern(".")) plot2opts(lpattern("--"))scheme(sj) 
graph save file4.gph, replace

graph combine file3.gph file4.gph, xcommon rows(1) ti("Figure 2b. Attitudinal Measures") scheme(sj) 

*Conditional fx on co-partisan governor?

*Table A3 Replication Code
reg wearmask i.treat c.liberal c.copart_gov c.liberal#i.treat c.copart_gov#i.treat c.liberal#c.copart_gov#i.treat age female black latino other_race education 
logit buy_mask i.treat c.liberal c.copart_gov c.liberal#i.treat c.copart_gov#i.treat c.liberal#c.copart_gov#i.treat age female black latino other_race education 
reg best_soc i.treat c.liberal c.copart_gov c.liberal#i.treat c.copart_gov#i.treat c.liberal#c.copart_gov#i.treat age female black latino other_race education 
reg wont_impact i.treat c.liberal c.copart_gov c.liberal#i.treat c.copart_gov#i.treat c.liberal#c.copart_gov#i.treat age female black latino other_race education 


*Figure 3a Replication Code
reg wearmask i.treat c.liberal c.copart_gov c.liberal#i.treat c.copart_gov#i.treat c.liberal#c.copart_gov#i.treat age female black latino other_race education 
margins, at(treat = (1 2 3) liberal=(0 1) copart_gov=(0)) l(90) 
marginsplot, x(treat) recast(scatter) yscale(range(3.5 6.5)) ylabel(3(1)6) xscale(range(1 3.1)) graphregion(color(white)) xtitle("") ytitle(Intention to Wear Mask) ti("Out-Partisan Governor") scheme(sj) 
graph save file1.gph, replace

reg wearmask i.treat c.liberal c.copart_gov c.liberal#i.treat c.copart_gov#i.treat c.liberal#c.copart_gov#i.treat age female black latino other_race education 
margins, at(treat = (1 2 3) liberal=(0 1) copart_gov=(1)) l(90) 
marginsplot, x(treat) recast(scatter) yscale(range(3.5 6.5)) ylabel(3(1)6) xscale(range(1 3.1)) graphregion(color(white)) xtitle("") ytitle(Intention to Wear Mask) ti("Co-Partisan Governor") scheme(sj) 
graph save file11.gph, replace

graph combine file1.gph file11.gph , xcommon rows(1) ti("Figure 3a. Wear Mask") scheme(sj) 

*Figure 3b Replication Code
reg best_soc i.treat c.liberal c.copart_gov c.liberal#i.treat c.copart_gov#i.treat c.liberal#c.copart_gov#i.treat age female black latino other_race education 
margins, at(treat = (1 2 3) liberal=(0 1) copart_gov=(0)) l(90) 
marginsplot, x(treat) recast(scatter) yscale(range(3.5 6.5)) ylabel(3(1)6) xscale(range(1 3.1)) graphregion(color(white)) xtitle("") ytitle(Best for Society)  ti("Out-Partisan Governor") scheme(sj) 
graph save file3.gph, replace

reg best_soc i.treat c.liberal c.copart_gov c.liberal#i.treat c.copart_gov#i.treat c.liberal#c.copart_gov#i.treat age female black latino other_race education 
margins, at(treat = (1 2 3) liberal=(0 1) copart_gov=(1)) l(90) 
marginsplot, x(treat) recast(scatter) yscale(range(3.5 6.5)) ylabel(3(1)6) xscale(range(1 3.1)) graphregion(color(white)) xtitle("") ytitle(Best for Society) ti("Co-Partisan Governor") scheme(sj) 
graph save file31.gph, replace

graph combine file3.gph file31.gph , xcommon rows(1) ti("Figure 3b. Best for Society") scheme(sj) 

*Figure 3c Replication Code
reg wont_impact i.treat c.liberal c.copart_gov c.liberal#i.treat c.copart_gov#i.treat c.liberal#c.copart_gov#i.treat age female black latino other_race education  
margins, at(treat = (1 2 3) liberal=(0 1) copart_gov=(0)) l(90) 
marginsplot, x(treat) recast(scatter) yscale(range(1.5 4.5)) ylabel(2(1)5) xscale(range(1 3.1)) graphregion(color(white)) xtitle("") ytitle(Won't Impact Spread)  ti("Out-Partisan Governor") scheme(sj) 
graph save file4.gph, replace

reg wont_impact i.treat c.liberal c.copart_gov c.liberal#i.treat c.copart_gov#i.treat c.liberal#c.copart_gov#i.treat age female black latino other_race education  
margins, at(treat = (1 2 3) liberal=(0 1) copart_gov=(1)) l(90) 
marginsplot, x(treat) recast(scatter)yscale(range(1.5 4.5)) ylabel(2(1)5) xscale(range(1 3.1)) graphregion(color(white)) xtitle("") ytitle(Won't Impact Spread) ti("Co-Partisan Governor") scheme(sj) 
graph save file41.gph, replace

graph combine file4.gph file41.gph , xcommon rows(1) ti("Figure 3c. Won't Impact Spread") scheme(sj) 


*Figure A1 Replication Code
logit buy_mask i.treat c.liberal c.copart_gov c.liberal#i.treat c.copart_gov#i.treat c.liberal#c.copart_gov#i.treat age female black latino other_race education 
margins, at(treat = (1 2 3) liberal=(0 1) copart_gov=(0)) l(90) 
marginsplot, x(treat) recast(scatter) yscale(range(0 .5)) ylabel(0(.1).5) xscale(range(1 3.1)) graphregion(color(white)) xtitle("") ytitle(Intention to Buy Mask) ti("Out-Partisan Governor") scheme(sj) 
graph save file2.gph, replace

logit buy_mask i.treat c.liberal c.copart_gov c.liberal#i.treat c.copart_gov#i.treat c.liberal#c.copart_gov#i.treat age female black latino other_race education 
margins, at(treat = (1 2 3) liberal=(0 1) copart_gov=(1)) l(90) 
marginsplot, x(treat) recast(scatter)  yscale(range(0 .5)) ylabel(0(.1).5) xscale(range(1 3.1)) graphregion(color(white)) xtitle("") ytitle(Intention to Buy Mask) ti("Co-Partisan Governor") scheme(sj) 
graph save file21.gph, replace

graph combine file2.gph file21.gph , xcommon rows(1) ti("Figure A1. Wear Mask") scheme(sj) 




